home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 23 / AACD 23.iso / AACD / Programming / tek / task / waitport.c < prev   
Encoding:
C/C++ Source or Header  |  2001-05-12  |  517 b   |  40 lines

  1.  
  2. #include "tek/exec.h"
  3. #include "tek/debug.h"
  4. #include "tek/kn/exec.h"
  5.  
  6. /* 
  7. **    TEKlib
  8. **    (C) 2001 TEK neoscientists
  9. **    all rights reserved.
  10. **
  11. **    TVOID TWaitPort(TPORT *msgport)
  12. **
  13. **    wait for a message-port to be non-empty.
  14. **
  15. */
  16.  
  17. TVOID TWaitPort(TPORT *msgport)
  18. {
  19.     TBOOL isempty;
  20.  
  21.     if (msgport)
  22.     {
  23.         for (;;)
  24.         {
  25.             kn_lock(&msgport->lock);
  26.  
  27.             isempty = TListEmpty(&msgport->msglist);
  28.  
  29.             kn_unlock(&msgport->lock);
  30.  
  31.             if (!isempty)
  32.             {
  33.                 return;
  34.             }
  35.             
  36.             TWait(msgport->sigtask, msgport->signal);
  37.         }
  38.     }
  39. }
  40.